package com.leinao.task;

import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.leinao.job.service.JobService;
import com.leinao.resourcesInfo.service.UserResourcesInfoService;
import com.leinao.user.BasicUserService;

/**
*
* 任务调度器
* created by wangshoufa
* 2018年8月28日 下午5:12:57
*
*/

@Component
public class ScheduleTasks {
	
	private Logger logger = LoggerFactory.getLogger(getClass());
	
	@Autowired
	private BasicUserService basicUserService;
	
	@Autowired
	private UserResourcesInfoService userResourcesInfoService;
	
	@Autowired
	private JobService jobService;
	
	/**
	 * 
	 * created by wangsf
	 * 
	 * @Scheduled(fixedRate = 5000) ：上一次开始执行时间点之后5秒再执行
	 * @Scheduled(fixedDelay = 5000) ：上一次执行完毕时间点之后5秒再执行
	 * @Scheduled(initialDelay=1000, fixedRate=5000) ：第一次延迟1秒后执行，之后按fixedRate的规则每5秒执行一次
	 * @Scheduled(cron="0 * * * * ?") ：通过cron表达式定义规则
	 * 
	 */
	@Async("taskExecutor")
	@Scheduled(cron = "0 */1 * * * ?")//每隔5min
	public void statisJobCountTask() {
		jobService.statisJobCount();
	}
	
	
	//@Async("taskExecutor")
	//@Scheduled(cron = "*/30 * * * * ?")
    /*public void statisResTask() {
        logger.info("schedule statisResGPUCPUMemoryDiskTask start: " + new Date());
        userResourcesInfoService.userResourcesInfoTask();
    }*/
	
	//统计带宽
	//@Async("taskExecutor")
	//@Scheduled(cron = "*/35 * * * * ?")
	/*public void userBandWidthResourceTask() {
		logger.info("schedule userBandWidthResourceTask start: " + new Date());
		userResourcesInfoService.userBandWidthResourceTask();
	}*/
	//更新汇总带宽
	//@Async("taskExecutor")
	//@Scheduled(cron = "*/36 * * * * ?")
    /*public void updateBandWidthResTask() {
        logger.info("schedule updateBandWidthResTask start: " + new Date());
        userResourcesInfoService.updateBandWidthRes();
    }*/
	
}
